home *** CD-ROM | disk | FTP | other *** search
/ Mac-Source 1994 July / Mac-Source_July_1994.iso / C and C++ / Libraries / MacTCP class library / MacTCP class headers / CTCPClient.h < prev   
Text File  |  1992-10-26  |  4KB  |  119 lines

  1. /*
  2.  
  3.   CTCPClient.h
  4.   Superclass:    CCollaborator
  5.  
  6.      The TCP client implementation for CTCP
  7.  
  8.   Copyright © NCSA, University of Illinois;    June 3, 1992
  9.   Eric Johnson, John Newlin and Igor Livshits
  10.   
  11.   This code may be used, modified, and distributed free of charge and obligation.
  12.   
  13. */
  14.  
  15. #define    _H_CTCPClient                                            //    Include this file only once
  16.  
  17. #include    <CCollaborator.h>                                //    Superclass definitions
  18. #include    "CTCP.h"
  19. #include    "CDNR.h"
  20.  
  21. #define        kDefaultRetries                5                    //    Retry an action five times
  22. #define        kDotAddressLength            16                //    Usual length of the dot address
  23. #define        kDNRSize                            8192            //    Memeory needed for a DNR ac =tion
  24.  
  25. /*=====================*/
  26. /*===---------------===*/
  27.  
  28. struct CTCPClient : CCollaborator
  29. Begin
  30. protected:
  31.     CTCP*                itsStream;                                    //    Our TCP stream object
  32.     long                numRetries;                                    //    How many times to try an action
  33.     Handle            itsBuffer;                                    // A place to store data that we read in.
  34.  
  35. public:
  36.     OSErr ITCPClient                                                //    Initialize this object
  37.             (    void                                                                //    No arguments
  38.             );
  39.     
  40.     void Dispose                                                        //    Destroy our object
  41.             (    void                                                                //    No arguments
  42.             );
  43.     
  44.     virtual OSErr Create                                        //    Create a stream
  45.             (    Size                         streamLength                //    Size of the stream buffer
  46.             );
  47.     virtual OSErr OpenConnection                        //    Open a connection
  48.             (    void                                                                //    No arguments
  49.             );
  50.     virtual OSErr WaitForConnection                    //    Wait for incoming connection
  51.             (    void                                                                //    No arguments
  52.             );
  53.     virtual OSErr SendData                                    //    Send some data over
  54.             (    Ptr                            data,                                //    Data to send
  55.                 Size                        length                            //    Size of oour data
  56.             );
  57.     virtual OSErr ReceiveData                                //    Receive data
  58.             (    Ptr*                        data,                                //    Where to place received data
  59.                 Size*                        length                            //    Size of our data
  60.             );
  61.     virtual OSErr MyBufferReceiveData                //    Receive data into specified buffer
  62.             (    Ptr                            data,                                //    Where to place received data
  63.                 Size*                        length                            //    Size of our data
  64.             );
  65.     virtual OSErr Close                                            //    Close current connection
  66.             (    void                                                                //    No arguments
  67.             );
  68.     virtual OSErr Abort                                            //    Abort current connection
  69.             (    void                                                                //    No arguments
  70.             );
  71.     virtual OSErr Quit                                            //    Quit our stream
  72.             (    void                                                                //    No arguments
  73.             );
  74.     virtual OSErr Kill                                            //    Kill our stream
  75.             (    void                                                                //    No arguments
  76.             );
  77.     
  78.     virtual void SetRetries                                    //    Set the retry count
  79.             (    long                            count                            //    How many times
  80.             );
  81.     virtual CTCP* GetStream                                    //    Fetch our stream object
  82.             (    void                                                                //    No arguments
  83.             );
  84.     virtual void SetAddress                                    //    Set up remote address (Resolve if necessary)
  85.             (    char*                            name,                            //    Name of the remote machine
  86.                 ip_addr                        address,                    //    Address of the remote machine
  87.                 ip_port                        port                            //    A remote port we are seeking
  88.             );
  89.     virtual OSErr ResolveAddress                        //    Resolve remote address
  90.             (    char*                            name,                            //    Name of the remote machine
  91.                 ip_addr*                    address                        //    Address of the remote machine
  92.             );
  93.             
  94.     virtual OSErr GetLocalAddress                        //    Fetch local IP address
  95.             (    ip_addr*                    address                        //    Address of our machine
  96.             );
  97.     virtual OSErr GetLocalDotAddress                //    Fetch local IP address as a string
  98.             (    char*                            dotAddress                //    Address of our machine in dot notation
  99.             );
  100.             
  101.             
  102.     virtual void ReadData                                // Fill the internal buffer from MacTCP 
  103.             ( void
  104.             );            
  105.     virtual void ReleaseBuffer                    // Dispose of itsBuffer.
  106.             ( void
  107.             );        
  108.     virtual void GetLine                                // Copy the next line into whatever line points too.
  109.             ( Ptr line                                                // A buffer to copy the line into.
  110.             );        
  111.     virtual Size HowLongNextLine                 // Return the number of bytes in the next line.
  112.             ( void
  113.             );    
  114.  
  115.  
  116. End;
  117.  
  118. /*===---------------===*/
  119. /*=====================*/